<?php
namespace app\index\controller;
/**
 * Created by Submint Text.
 * User: hetaoren<452649510@qq.com>
 * Date: 2017/03/10
 * Explain: 店铺控制器
 */
class Shops extends Base{
    public function index(){
        $this->assign("areaList",model('areas')->listQuery(0));
    	return $this->fetch("list");
    }
    /**
     * 获取分页
     */
    public function pageQuery(){
    	return model('Shops')->pageQuery();
    }
    /**
     * 获取
     */
    public function get(){
    	return model('Shops')->get((int)Input("post.id"));
    }
    /**
     * 跳去编辑页面
     */
    public function toEdit(){
    	$id = input("id/d",0);
	    $object = model('Shops')->get($id);
	    $data['object'] = $object;
    	$data['areaList'] = model('areas')->listQuery(0);   
        //店长        
        $data['keeperList'] = model('staffs')->field('staffName,staffId,shopId')->where(['dataFlag'=>1,'staffRoleId'=>2,'shopId'=>['in','0,'.$id]])->select();
        //店员        
        $data['clerkList'] = model('staffs')->field('staffName,staffId,shopId')->where(['dataFlag'=>1,'staffRoleId'=>3,'shopId'=>['in','0,'.$id]])->select();
    	return $this->fetch("edit",$data);
    }
    /**
     * 新增
     */
    public function add(){
    	return model('Shops')->add();
    }
    /**
     * 编辑
     */
    public function edit(){
        return model('Shops')->edit();
    }
    /**
     * 删除
     */
    public function del(){
        return model('Shops')->del();
    }
}
